package edu.whu.demo.dao;

import edu.whu.demo.domain.Supplier;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jiaxy
 * @since 2022-11-02
 */
@Mapper
public interface SupplierDao extends BaseMapper<Supplier> {

    @Select("select * from supplier s" +
            " inner join product_supplier ps on s.id=ps.supplier_id" +
            " where ps.product_id = #{productId}")
    public List<Supplier> findSuppliersByProduct(String productId);

   /* @Insert("insert into supplier(id,email,name,phone) values (#{id},#{email},#{name},#{phone})")
    @SelectKey(statement="select last_insert_id()",keyProperty = "id",keyColumn = "id",resultType = long.class,before = false)
    int insert(Supplier supplier);*/
}
